package com.example.annotation.controller;

import com.example.annotation.annotation.OpLog;
import com.example.annotation.enums.OpType;
import java.util.HashMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: v_jxchi
 * @date: 2020/11/27 18:11
 * @description:
 */
@RestController
public class TestController {

    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "/1")
    @OpLog(opType = OpType.QUERY, opItem = "order", opItemIdExpression = "#id")
    public @ResponseBody
    HashMap view(@RequestParam(name = "id") String id) {
        return new HashMap();
    }

    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "/2")
    @OpLog(opType = OpType.QUERY, opItem = "order", opItemIdExpression = "#orderVo.id")
    public @ResponseBody
    HashMap update(OrderVO orderVo) {
        return new HashMap();
    }

    @RequestMapping(method = {RequestMethod.GET, RequestMethod.POST}, value = "/3")
    @OpLog(opType = OpType.QUERY, opItem = "order", opItemIdExpression = "#OrderVO.id")
    public @ResponseBody OrderVO insert() throws Exception {
        OrderVO orderVO = new OrderVO();
        orderVO.setId(100);
        return orderVO;
    }


    public static class OrderVO {

        private Integer id;

        public Integer getId() {
            return id;
        }

        public void setId(Integer id) {
            this.id = id;
        }
    }
}
